import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;

/**
 * @author Zero
 */
public class Panel extends JPanel {

	private static final long serialVersionUID = 5469183274534873097L;

	public Panel() {
        setOpaque(false);
        setBorder(new EmptyBorder(5, 5, 5, 5));
    }

    @Override
    protected void paintComponent(Graphics g) {
        Graphics2D g2d = (Graphics2D) g;
        g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

        //背景
        g2d.setColor(new Color(255, 255, 255, 150));
        g2d.fillRoundRect(3, 3, getWidth() - 7, getHeight() - 7, 20, 20);

        //标题条
        g2d.setColor(Color.white);
        g2d.setClip(0, 0, getWidth(), 40);
        g2d.fillRoundRect(1, 3, getWidth() - 2, getHeight() - 1, 20, 20);
        g2d.setClip(null);

        //边框
        g2d.setColor(Color.darkGray);
        g2d.setStroke(new BasicStroke(6));
        g2d.drawRoundRect(3, 3, getWidth() - 7, getHeight() - 7, 20, 20);

        //标题
        g2d.setFont(new Font("Arial", Font.BOLD, 16));
        g2d.setColor(new Color(0x59F6C6));
        g2d.drawString("Zero's Swing UI", 15, 30);
    }
}